﻿<Application 
    x:Class="WP7Square.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:layout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:converters="clr-namespace:WP7Square.Converters"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    
        >

    <!--RootFrame points to and loads the first page of your application-->
    <Application.RootVisual>
        <phone:PhoneApplicationFrame x:Name="RootFrame" >
            <phone:PhoneApplicationFrame.Template>
                <ControlTemplate TargetType="ContentControl">
                    <layout:TransitioningContentControl HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                                                            Background="{TemplateBinding Background}"
                                                            Style="{StaticResource TransitioningContentControlStyle}"                                                            
                                                            Content="{TemplateBinding Content}"
                                                            />
                </ControlTemplate>
            </phone:PhoneApplicationFrame.Template>
        </phone:PhoneApplicationFrame>
    </Application.RootVisual>

    <!-- Resources for following the Windows Phone design guidelines -->
    <Application.Resources>       
        <!-- main menu styles -->
        <Style x:Key="MainMenuItemTitleStyle" TargetType="TextBlock">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Width" Value="365" />
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}" />
            <Setter Property="FontSize" Value="62" />
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />
            <Setter Property="Margin" Value="18, 4, 0, 0" />
        </Style>

        <Style x:Key="MainMenuSubItemTitleStyle" TargetType="TextBlock">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Width" Value="365" />
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="33.2"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="Margin" Value="18, -9, 0, 10"/>
        </Style>

        <Style x:Key="MainMenuItemIconStyle" TargetType="Image">
            <Setter Property="Height" Value="62"/>
            <Setter Property="Width" Value="62"/>
        </Style>

        <Style x:Key="ToggleItemStateTextStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="26.667" />
            <Setter Property="Margin" Value="0,0,0,11" />
            <Setter Property="TextWrapping" Value="Wrap" />

        </Style>

        <Style x:Key="PhoneToggleSwitch" TargetType="ToggleButton">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Height" Value="50"/>
            <Setter Property="Padding" Value="8,5,8,12"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToggleButton">
                        <Grid x:Name="grid" Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Pressed" />
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="RightBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="CheckFill" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CheckStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="Checked" To="Unchecked">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="Width" From="64" To="0">
                                                    <DoubleAnimation.EasingFunction>
                                                        <CubicEase EasingMode="EaseInOut"/>
                                                    </DoubleAnimation.EasingFunction>
                                                </DoubleAnimation>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition From="Unchecked" To="Checked">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="Width" From="0" To="64">
                                                    <DoubleAnimation.EasingFunction>
                                                        <CubicEase EasingMode="EaseInOut"/>
                                                    </DoubleAnimation.EasingFunction>
                                                </DoubleAnimation>
                                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="Margin">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Thickness>0,2,4,2</Thickness>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Checked" >
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="Width" Duration="0" To="64"/>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="LeftBorder" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Thickness>0,2,4,2</Thickness>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unchecked"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused"/>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>

                            <Border Margin="{StaticResource PhoneTouchTargetLargeOverhang}">
                                <Grid Margin="{TemplateBinding Padding}" Width="89" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Border x:Name="LeftBorder" Grid.Column="0" Margin="0,2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="3,3,0,3" Width="0" VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
                                        <Rectangle x:Name="CheckFill" Fill="{TemplateBinding Foreground}" VerticalAlignment="Stretch" Margin="4,4,0,4"/>
                                    </Border>
                                    <Rectangle x:Name="Thumb" Grid.Column="1" VerticalAlignment="Stretch" Width="20" Fill="{StaticResource PhoneForegroundBrush}" />
                                    <Border x:Name="RightBorder" Grid.Column="2" Margin="4,2,0,2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,3,3,3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}"/>
                                </Grid>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <converters:ImageUriConverter x:Key="imgUrlConverter" />
        <!-- set the background image to be used according to the current theme in the uriconverter class -->
        <Image x:Key="BackgroundImage1" Source="Images\dark\background.png" />
       <!-- <Image x:Key="BackgroundImage2" Source="{Binding Source={StaticResource BackgroundImage1}, Converter={StaticResource imgUrlConverter}, ConverterParameter={StaticResource PhoneBackgroundColor}}" /> -->
        <ImageBrush x:Key="BackgroundBrush" ImageSource="Images\dark\background.png" />




        <Style x:Key="TransitioningContentControlStyle" TargetType="layout:TransitioningContentControl">
            <Setter Property="Transition" Value="SlideLeft" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="layout:TransitioningContentControl">
                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="PresentationStates">
                                    <vsm:VisualState x:Name="Normal">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Visibility)">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>
                                                            Collapsed
                                                        </Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="SlideRight">
                                        <Storyboard>
                                            <DoubleAnimation From="-480" To="0" Duration="00:00:00.500" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuinticEase EasingMode="EaseInOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                            <DoubleAnimation From="0" To="480" Duration="00:00:00.500" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuinticEase EasingMode="EaseInOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="SlideLeft">
                                        <Storyboard>
                                            <DoubleAnimation From="480" To="0" Duration="00:00:00.500" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuinticEase EasingMode="EaseInOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                            <DoubleAnimation From="0" To="-480" Duration="00:00:00.500" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuinticEase EasingMode="EaseInOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Grid>
                                <ContentPresenter x:Name="PreviousContentPresentationSite" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    <ContentPresenter.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </ContentPresenter.RenderTransform>
                                </ContentPresenter>
                                <ContentPresenter x:Name="CurrentContentPresentationSite" RenderTransformOrigin=".5,.5" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                    <ContentPresenter.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </ContentPresenter.RenderTransform>
                                </ContentPresenter>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Touch Target area -->
        <Thickness x:Key="PhoneTouchTargetOverhang">12</Thickness>

        <!-- Default border size-->
        <Thickness x:Key="PhoneDefaultBorderThickness">3</Thickness>

        <!-- Font names -->
        <FontFamily x:Key="PhoneFontFamilyNormal">Segoe WP</FontFamily>
        <FontFamily x:Key="PhoneFontFamilyLight">Segoe WP Light</FontFamily>
        <FontFamily x:Key="PhoneFontFamilySemiLight">Segoe WP SemiLight</FontFamily>
        <FontFamily x:Key="PhoneFontFamilySemiBold">Segoe WP Semibold</FontFamily>

        <!-- Font sizes -->
        <!--14pt-->
        <System:Double x:Key="PhoneFontSizeSmall">18.667</System:Double>
        <!--15pt-->
        <System:Double x:Key="PhoneFontSizeNormal">20</System:Double>
        <!--17pt-->
        <System:Double x:Key="PhoneFontSizeMedium">22.667</System:Double>
        <!--19pt-->
        <System:Double x:Key="PhoneFontSizeMediumLarge">25.333</System:Double>
        <!--24pt-->
        <System:Double x:Key="PhoneFontSizeLarge">32</System:Double>
        <!--32pt-->
        <System:Double x:Key="PhoneFontSizeExtraLarge">42.667</System:Double>
        <!--54pt-->
        <System:Double x:Key="PhoneFontSizeExtraExtraLarge">72</System:Double>

        <!-- TextBlock styles -->
        <Style x:Key="PageTitleStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Margin" Value="10"/>
        </Style>


        <Style x:Key="PhoneTextApplicationNameStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Margin" Value="20"/>
        </Style>

        <Style x:Key="PhoneTextTitleNameStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeExtraExtraLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Margin" Value="20, 5, 20 ,0"/>
        </Style>

        <Style x:Key="PhoneTextBodyTextStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="LineHeight" Value="28"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
            <!--<Setter Property="Margin" Value="24, 11, 24, 24"/>-->
            <Setter Property="Margin" Value="10, 5, 5, 5"/>
        </Style>

        <Style x:Key="DoubleLineListTitleTextStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeExtraLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Margin" Value="18, 4, 18, 0"/>
        </Style>

        <Style x:Key="DoubleLineListSubTitleTextStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}"/>
            <Setter Property="Margin" Value="18, -13, 18, 10"/>
        </Style>


        <!-- Triple Line List -->
        <Style x:Key="TripleLineListTitleTextStyleLarge" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeExtraLarge}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Margin" Value="0, 0, 0, -3"/>
        </Style>

        <Style x:Key="TripleLineListTitleTextStyleMedium" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="Margin" Value="0, -3, 0, 0"/>
        </Style>

        <Style x:Key="TripleLineListTitleTextStyleSmall" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeSmall}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}"/>
            <Setter Property="Margin" Value="0, -5, 0, 5"/>
        </Style>

        <!--ListBoxItemStyle-->
        <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Disabled"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected"/>
                                    <VisualState x:Name="Selected"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused"/>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- ListBox Style -->
        <Style x:Key="ListBoxStyle" TargetType="ListBox">
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"/>
            <Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyle}"/>
        </Style>
    </Application.Resources>

</Application>